<header id="header" class="layui-bg-gray">
  <div class="layui-header layui-container header-content">
    <!-- logo start -->
    <a href="/">
      <img class="logo" src="/static/images/ffmall.jpg" alt="FFmall logo"></a>
    <!-- logo end -->
    {% if not request.path == '/detail/' %}
      <!--search start-->
      <div class="search">
        <input type="text" name="search" id="inputKeywords" placeholder="请输入您心仪的宝贝">
        <button type="submit" class="btn" id="search-btn">搜索</button>
      </div>
      <!--search end-->
    {% endif %}
    <!-- nav start -->
    <div class="nav">
      <ul class="layui-nav layui-bg-gray" lay-bar="disabled">
        <li class="layui-nav-item">
          <a href="/shopping_car/"><i class="layui-icon layui-icon-cart"></i>购物车{% if request.user.is_authenticated %}<span class="layui-badge">{{ request.session.total_num }}</span>{% endif %}</a>
        </li>
        <li class="layui-nav-item">
          <a href="/order/show/">全部订单<span class="layui-badge-dot"></span></a>
        </li>
        {% if request.user.is_authenticated %}
          <li class="layui-nav-item" lay-unselect="">
            <a href="javascript:;">
              {% if request.user.customer.customerdetail.portrait %}
                <img src="{{ request.user.customer.customerdetail.portrait }}" class="layui-nav-img" alt="">
              {% else %}
                <img src="https://cdn.ilayuis.com/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                     class="layui-nav-img" alt="">
              {% endif %}
              <span id="nickname">{% if request.user.customer.customerdetail.nickname %}
                {{ request.user.customer.customerdetail.nickname }}{% else %}
                {{ user.email }}{% endif %}</span><!--有昵称显示昵称，没有则显示邮箱-->
            </a>
            <dl class="layui-nav-child">
              <dd><a href="/detail/">个人信息</a></dd>
              <dd><a href="javascript:;">足迹</a></dd>
              <hr>
              <dd><a href="/logout">退出</a></dd>
            </dl>
          </li>
        {% else %}
          <li class="layui-nav-item">
            <a class="login" id="login" href="/login/">亲,请登录</a>
            <a class="register" href="/register/">免费注册</a>
          </li>
        {% endif %}
      </ul>
    </div>
    <!-- nav end -->
  </div>
</header>
